<?php
/**
 * +----------------------------------------------------------------------
 * | 表单验证器
 * +----------------------------------------------------------------------
 *                      _ooOoo_
 *                     o8888888o            | AUTHOR: 杜云
 *                     88" . "88            | EMAIL: 987772927@qq.com
 *                     (| -_- |)            | QQ: 987772927
 *                     O\  =  /O            | WECHAT: 987772927
 *                  ____/`---'\____
 *                .'  \\|     |//  `.
 *               /  \\|||  :  |||//  \
 *              /  _||||| -:- |||||-  \
 *              |   | \\\  -  /// |   |
 *              | \_|  ''\-/''  |   |
 *              \  .-\__  `-`  ___/-. /
 *            ___`. .'  /-.-\  `. . __
 *         ."" '<  `.___\_<|>_/___.'  >'"".
 *        | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 *        \  \ `-.   \_ __\ /__ _/   .-` /  /
 *   ======`-.____`-.___\_____/___.-`____.-'======
 *                      `=-='
 * +----------------------------------------------------------------------
 */
declare(strict_types=1);
namespace App\Request;

use Hyperf\Validation\Request\FormRequest;
use Hyperf\Validation\Rule;
class DriverRequest extends FormRequest
{

    public function authorize(): bool
    {
        return true;
    }
    public function rules(): array
    {
        return [
            'id' => ['required'],
            'dept_id' => ['required'],
            'account' => ['required','max:15','unique:users'],
            'realname' => ['required','string','max:20'],
            'phone' => ['required','max:11','regex:/^1[^0-2]\d{9}$/'],
        ];
    }
    public function attributes(): array
    {
        return [
            'dept_id' => '部门',
            'account' => '用户账号',
            'realname' => '真实姓名',
            // 'driver_id_number' => '身份证号',
            'phone' => '司机电话',
        ];
    }
    public function messages(): array
    {
        return [
            'dept_id.required' => '请选择部门',
            'account.unique' => ':attribute已存在',
            'account.regex' => ':attribute格式有误',
            // 'driver_id_number.regex' => '请输入正确身份证号',
        ];
    }
    protected $scenes = [
        'add' => ['account','realname','account'],
        'edit' => ['id','dept_id','realname'],
    ];
}
